import axios from 'poros/http';

// const BASE_API = 'http://10.110.96.192:8030';
const BASE_API = '';

//新增拜访
export const postAddVisit = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/insert`,
    method: 'post',
    data,
  });

//新增拜访
export const postVisitTableList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/listByPage`,
    method: 'post',
    data,
  });

//线索弹框list分页查
export const postClueTableList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/leadsByPage`,
    method: 'post',
    data,
  });

//商机弹框list分页查
export const postBusinessTableList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/oppByPage`,
    method: 'post',
    data,
  });

//获取拜访基本信息详情
export const getVisitInfo = id =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/query/${id}`,
    method: 'get',
  });

// 查询线索跟进详情
export const getClueFollowDetails = leadsNo =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/leads/getLeadsByNo/${leadsNo}`,
    method: 'get',
  });

//获取拜访线索详情详情
export const getVisitCurInfo = params =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/queryLeads/`,
    method: 'get',
    params,
  });

//获取拜访线索详情详情
export const getVisitBusinessInfo = params =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/queryOpportunity/`,
    method: 'get',
    params,
  });

//获取客户团队详情
export const getCustomerTableList = params =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/findTeam`,
    method: 'get',
    params,
  });

//获取客户弹框list
export const postCustomerList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/findContact?name=${data.cname}`,
    method: 'post',
    data,
  });

//获取我方弹框list
export const getMyList = params =>
  axios({
    url: `${BASE_API}/api/poros-permission/secStaff/list`,
    method: 'get',
    params,
  });

//取消拜访
export const postCancelVisit = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/cancel`,
    method: 'post',
    data,
  });

//事项跟进tab的table
export const getFollowMatter = params =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/queryMatter`,
    method: 'get',
    params,
  });

//新增跟进事项
export const postAddMatter = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/matter/insertMatter`,
    method: 'post',
    data,
  });

//删除跟进事项
export const postDeleteMatter = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/matter/deleteMatter`,
    method: 'post',
    data,
  });

//获取跟进事项详情
export const getMatterInfo = id =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/matter/query/${id}`,
    method: 'get',
  });

//修改跟进事项
export const postEditMatter = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/matter/updateMatter`,
    method: 'post',
    data,
  });

//新增会议纪要
export const postAddMeetRecord = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/minutes/insert`,
    method: 'post',
    data,
  });

//查询会议纪要List
export const postMeetRecordList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/minutes/list`,
    method: 'post',
    data,
  });

//删除会议纪要
export const postDeleteMeetRecord = (data, visitNo) =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/minutes/deleteMinutes?visitNo=${visitNo}`,
    method: 'post',
    data,
  });

//导出会议纪要模板
export const postDownMeetModel = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/minutesDetail/downExcelImportTemplate`,
    method: 'post',
    responseType: 'arraybuffer',
    hasInterceptors: true,
    data,
  });

//导入会议纪要
export const postUpMeet = file => {
  const formData = new FormData();
  formData.append('file', file);
  return axios({
    url: `${BASE_API}/api/salesforecast-service/minutesDetail/importExcel`,
    headers: { 'Content-Type': 'nultipart/form-data' },
    method: 'post',
    data: formData,
  });
};

//上传附件
export const postUpFile = (file, type, id) => {
  const formData = new FormData();
  formData.append('file', file);
  return axios({
    url: `${BASE_API}/api/salesforecast-service/visit/upload/${type}/${id}`,
    headers: { 'Content-Type': 'nultipart/form-data' },
    method: 'post',
    data: formData,
  });
};

// 商机详情接口
export const getBusinessDetail = opportunityNo =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/opportunity/getByOpportunityNo/${opportunityNo}`,
    method: 'get',
  });

//获取会议纪要明细
export const postMeetDetail = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/minutesDetail/list`,
    method: 'post',
    data,
  });

//新增会议纪要明细
export const postAddMeetDetail = (data, id, del, add) =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/minutesDetail/insert?id=${id}&isDelete=${del}&isInsert=${add}`,
    method: 'post',
    data,
  });

//新增会议纪要明细
export const postFileTable = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/attachment/listByGroup?isGroup=true`,
    method: 'post',
    data,
  });

//删除附件
export const postFileDelete = (data, id) =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/attachmentDelete?visitNo=${id}`,
    method: 'post',
    data,
  });

//获取拜访线索详情详情
export const getVisitLog = params =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/queryLog`,
    method: 'get',
    params,
  });

//绑定我方或客户团队
export const postBindTeam = (data, type, visitNo) =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/bindTeam?type=${type}&visitNo=${visitNo}`,
    method: 'post',
    data,
  });

//删除我方或客户团队
export const postDeleteCustomer = (data, type, visitNo) =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visitTeam/delete?type=${type}&visitNo=${visitNo}`,
    method: 'post',
    data,
  });

//删除拜访
export const postDeleteVisit = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/deleteVisit`,
    method: 'post',
    data,
  });

//删除关联线索、商机
export const getDeleteInfo = params =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/deleteOppAndLeads`,
    method: 'get',
    params,
  });

//绑定线索、商机
export const postAddInfo = (data, type) =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/bindOppAndLeads?type=${type}`,
    method: 'post',
    data,
  });

//会议纪要发送邮件
export const postSendEmail = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/minutes/sendEmail`,
    method: 'post',
    data,
  });

//导出拜访列表
export const postDownVisitlist = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/visit/listExportTemplate`,
    method: 'post',
    responseType: 'arraybuffer',
    hasInterceptors: true,
    data,
  });

//导出会议纪要详情
export const getDownMeetDetail = params =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/minutesDetail/export`,
    method: 'get',
    responseType: 'arraybuffer',
    hasInterceptors: true,
    params,
  });
